﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Boom.Navigation
{
    public class Info:DrawableGameComponent
    {
        private SpriteBatch _SBatch;
        private Vector2 _PositionLive;
        private Vector2 _PositionScore;
        private Vector2 _PositionMaxBoom;
        private Vector2 _PositionLenght;
       

        private readonly SpriteFont _Font;
        private readonly Color _FontColor;

        private int _InfLive;
        private int _InfScore;
        private int _InfMaxBoom;
        private int _InfLenght;
        private int _CountMonster;

        public int InfLive
        {
            get { return _InfLive; }
            set { _InfLive = value; }
        }

        public int InfScore
        {
            get { return _InfScore; }
            set { _InfScore = value; }
        }

        public int InfMaxBoom
        {
            get { return _InfMaxBoom; }
            set { _InfMaxBoom = value; }
        }

        public int InfLenght
        {
            get { return _InfLenght; }
            set { _InfLenght = value; }
        }

        public int CountMonster
        {
            get { return _CountMonster; }
            set
            {
                if (_CountMonster == 0) _CountMonster = value;
                if (_CountMonster > value)
                {
                    _InfScore += (_CountMonster - value) * Config.RankScore;    
                }
            }
        }

        private Vector2 Position
        {
            set
            {
                _PositionLive = value;
                _PositionScore = new Vector2(value.X, value.Y + Config.EnterLine);
                _PositionMaxBoom = new Vector2(value.X, value.Y + Config.EnterLine * 2);
                _PositionLenght = new Vector2(value.X, value.Y + Config.EnterLine * 3);
            }
        }

        public Info(Game Mygame, SpriteFont Font, Color FontColor)
            : base(Mygame)
        {
            _Font = Font;
            _FontColor = FontColor;
            _SBatch = (SpriteBatch)Mygame.Services.GetService(typeof(SpriteBatch));
            Position = Config.PositionInfo;
        }

        public override void Draw(GameTime gameTime)
        {
            //Hiện thông tin số mạng của nhân vật
            _SBatch.DrawString(_Font, InfLive.ToString(), _PositionLive + Config.ShadowString, Color.Black);
            _SBatch.DrawString(_Font, InfLive.ToString(), _PositionLive, _FontColor);
           

            //Hiện thông tin điểm số 
            _SBatch.DrawString(_Font, InfScore.ToString(), _PositionScore + Config.ShadowString, Color.Black);
            _SBatch.DrawString(_Font, InfScore.ToString(), _PositionScore, _FontColor);
           

            //Hiện thông tin số boom tối đa
            _SBatch.DrawString(_Font, InfMaxBoom.ToString(), _PositionMaxBoom + Config.ShadowString, Color.Black);
            _SBatch.DrawString(_Font, InfMaxBoom.ToString(), _PositionMaxBoom, _FontColor);
           

            //Hiện thông tin độ dài boom
            _SBatch.DrawString(_Font, InfLenght.ToString(), _PositionLenght + Config.ShadowString, Color.Black);
            _SBatch.DrawString(_Font, InfLenght.ToString(), _PositionLenght, _FontColor);
            

            base.Draw(gameTime);
        }
    }
}
